package com.github.linmt.dbdoc4j;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSON;
import com.github.linmt.dbdoc4j.metadata.model.standard.TableModel;
import com.github.linmt.dbdoc4j.metadata.query.mysql.MysqlMetaDataQuery;

import java.util.List;
import java.util.stream.Collectors;

/**
 * User: Linmt
 * Date: 2022/12/11
 * Time: 11:30
 * Description: No Description
 */
public class Main {

    public static void main(String[] args) {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl("jdbc:mysql://192.168.48.48:3306/t2?useAffectedRows=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8");
        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSource.setUsername("root");
        dataSource.setPassword("123456");
        MysqlMetaDataQuery mysqlMetaDataQuery = new MysqlMetaDataQuery(dataSource);
        List<TableModel> tableModels = mysqlMetaDataQuery.queryTableMetaData(new String[]{"t_sys*", "t_sys_user_c*"}, new String[]{"view_*", "t_sys_user_c*"});
        System.out.println(JSON.toJSONString(tableModels.stream().map(TableModel::getTableName).collect(Collectors.toList())));
    }
}
